/*
 *  Copyright 2005 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.questionnaire;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.questionnaire.Questionnaire;
import com.blandware.atleap.persistence.core.PageDAO;
import com.blandware.atleap.persistence.exception.DeleteException;

import java.util.Map;

/**
 * <p>DAO for questionnaires.</p>
 * <p><a href="QuestionnaireDAO.java.html"><i>View source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.2 $ $Date: 2006/06/16 15:21:27 $
 */
public interface QuestionnaireDAO extends PageDAO {
	// ~ CRUD methods ================================================================

	/**
	 * Creates new questionnaire.
	 *
	 * @param questionnaire      Value object that represents what questionnaire
     * must be created
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which
     *                      link URI in the annotation to
	 *                      corresponding object (resource or page) if it exists
	 * @return ID of created questionnaire
	 */
	public Long createQuestionnaire(Questionnaire questionnaire, Map linkedObjects);

	/**
	 * Retrieves questionnaire with specified ID.
	 *
	 * @param questionnaireId ID to search by
	 * @return Questionnaire with specified ID or null if no item with specified ID exists in database
	 */
	public Questionnaire retrieveQuestionnaire(Long questionnaireId);

	/**
	 * Updates questionnaire.
	 *
	 * @param questionnaire      Questionnaire to update
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the annotation or body to
	 *                      corresponding object (resource or page) if it exists
	 */
	public void updateQuestionnaire(Questionnaire questionnaire, Map linkedObjects);

	/**
	 * Updates questionnaire ignoring linked objects.
	 *
	 * @param questionnaire      Questionnaire to update
	 */
	public void updateQuestionnaire(Questionnaire questionnaire);

	/**
	 * Deletes questionnaire.
	 *
	 * @param questionnaire item to delete
	 * @throws com.blandware.atleap.persistence.exception.DeleteException
	 *          if questionnaire cannot be deleted
	 */
	public void deleteQuestionnaire(Questionnaire questionnaire) throws DeleteException;

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of questionnaires.
	 *
	 * @param queryInfo Object that contains information about how to filter
     * and sort data
	 * @return Collection of questionnaires
	 */
	public PartialCollection listQuestionnaires(QueryInfo queryInfo);

    /**
     * Creates a copy of a questionnaire making it unfixed and inactive.
     *
     * @param questionnaire questionnaire to copy
     * @param suffixMap map of content locale identifiers to suffixes which
     * will be added to copy title
     * @return new questionnaire
     */
    public Questionnaire copyQuestionnaire(Questionnaire questionnaire,
                                           Map suffixMap);

	// ~ Finders ================================================================

	/**
	 * Finds questionnaire by URI
	 *
	 * @param questionnaireUri URI of questionnaire to search by
	 * @return Questionnaire or null if nothing was found
	 */
	public Questionnaire findQuestionnaireByUri(String questionnaireUri);
}
